function addControlPoint(obj,name)

% This file is part of CISNE.
%
%     CISNE is free software: you can redistribute it and/or modify
%     it under the terms of the GNU General Public License as published by
%     the Free Software Foundation, either version 3 of the License, or
%     any later version.
%
%     CISNE is distributed in the hope that it will be useful,
%     but WITHOUT ANY WARRANTY; without even the implied warranty of
%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%     GNU General Public License for more details.
%
%     You should have received a copy of the GNU General Public License
%     along with CISNE.  If not, see <http://www.gnu.org/licenses/>.

% Copyright 2011. Jose Maria Garcia-Valdecasas Bernal

model=get(obj.m_tree,'model');
root=obj.m_tree.Root();
for j=0:get(root,'ChildCount')-1
    child=root.getChildAt(j);
    kind=child.getValue();
    kind=char(kind(2));
    if (strcmp(kind,'CPOINTS'))
        %we add a new child in this node
        parent=child;
        type=['point_' regexprep(name,'\s+','_')];
        child=uitreenode('v0',{'unselected',type},name,[], true);
        model.insertNodeInto(child,parent,parent.getChildCount());
        %generate data for propertygrid
        
        obj.m_grids.(type)=...
            {'X', 'X Coordinate', 'num',0;...
            'Y', 'Y Coordinate', 'num',0};
        obj.m_tree.setSelectedNode(child);
        handles=guidata(obj.m_figure);
        handles.DisplayWidget.setAction('addCPoint');
        handles.DisplayWidget.addCPoint(type);
        set(handles.figure1,'Pointer','crosshair');
        
    end
end

end